% MANDELBROT_DRIVER Example of a call to the mandelbrot functions
%
% HISTORY
%
%   20100506 KP - Initial version
%   20110506 KP - Figure per revision and cosmetic changes
%   20120510 KP - Added error graph
%
% AUTHOR
%
%   Koen Poppe, Department of Computer Science,
%   Katholieke Universiteit Leuven, Celestijnenlaan 200A,
%   B-3001 Heverlee, Belgium
%   Email:  Koen.Poppe@cs.kuleuven.be
%
clear;clc;close all

%% Parameters for an interesting part of the complex space
center  = -0.7465 + 0.1240i;
radius  = 0.0037;
maxiter = 64;


%% Calculate for a range of revisions

% Alle stapgroottes
stepsv=[100 250 500 1000];
% Alle revisies
revisions = [0:9 99];
times=zeros(numel(stepsv),numel(revisions))
% Iterate over steps
for stepj=1:numel(stepsv)
    steps=stepsv(stepj)
    R_tilde_ref = mandelbrot_08(center,radius,steps,maxiter);
    % Iterate over revisions
    for revisioni = 1:numel(revisions),
        
        % Select the revision and the corresponding function
        revision = revisions(revisioni);
        mandelbrot_fun = str2func(sprintf('mandelbrot_%02i',revision));
        fprintf('- Testing %s ... ',func2str(mandelbrot_fun));
        
        % Run and time the function
        tic
        R_tilde = mandelbrot_fun(center,radius,steps,maxiter);
        times(stepj,revisioni)=toc;
        
        max_abs_err = max(abs((R_tilde(:)-R_tilde_ref(:))));
        fprintf(' max.abs.err.: %g\n', max_abs_err );
    end
end
%%
save('times','times')
plottimes